<style>
    .right_side_head_line{
        padding-left:60px;
    }
    .right_side_operate_area{
        margin-top:10px;
    }
    .right_side_details .right_side_operate_area{
        border-bottom:0px;
    }
    .right_side_head_line li{
        margin:0 15px 0 0;
        width:auto;
    }
    #barcontainer{
    margin-top:90px;
        width: 550px;
        height: 350px;
        float: left;
    }
    #piecontainer{
    margin-top:30px;
        width: 550px;
        height: 350px;
        float: right;
    }
</style>
<?php 
 	echo $javascript->link('highcharts/highcharts.js');
    $path=Router::url(array('controller' => '/', 'action' =>''), true);
?>
<div class="right_side_scollbar" style="min-height:580px;">
	<div class="right_side_operate_area">
		<div class="right_side_title right" style="padding-top:11px;">
			 <?php 
			 $user=$session->read('User');
			 if($user['isadmin']||$user['isvisitor']){
				$grouplist=array_merge(array(""=>"请选择模块"),$grouplist);
		    	echo $form->select('ddlgroup',$grouplist,$group_mod_id, null,null);
			 }
		    	?>
		</div>
	</div>
	
    <div class="detail_info_panel">
        <div id='barcontainer'></div>
        <div id='piecontainer'></div>
    <?php
        $str_inds = "";
        $str_comps = "";
        $piepoint ="";
        $i = 0;
        unset($ind_comps[0]);
        foreach($ind_comps as $ind_comp){
            $str_inds .= "'".$ind_comp["codevalues"]["value"]."',";
            $str_comps .= $ind_comp[0]["comps"].",";
            if($i == 0){
                $piepoint .= "{
                                name:'".$ind_comp["codevalues"]["value"]."',
                                y:".$ind_comp[0]["comps"].",
                                sliced: true,
                                selected: true
                               },";
            }else if($i == (count($ind_comps)-1)){
                $piepoint .= "['".$ind_comp["codevalues"]["value"]."',".$ind_comp[0]["comps"]."]";
            }else{
                $piepoint .= "['".$ind_comp["codevalues"]["value"]."',".$ind_comp[0]["comps"]."],";
            }
            $i++;
        }
        $str_inds = rtrim($str_inds,",");
        $str_comps = rtrim($str_comps,",");
    ?>
        <script type="text/javascript">
        $(function () {
            var chart;
            $(document).ready(function() {
                chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'barcontainer',
                        type: 'column',
                        margin: [ 50, 50, 100, 80]
                    },
                    title: {
                        text: '<?php echo "企业信息来源分布柱状图"; ?>'
                    },
                    xAxis: {
                        categories: [<?php echo $str_inds; ?>],
                        labels: {
                            rotation: -45,
                            align: 'right',
                            style: {
                                fontSize: '13px',
                                fontFamily: 'Verdana, sans-serif'
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        title: {
                            text: '企业数（个）'
                        }
                    },
                    legend: {
                        enabled: false
                    },
                    tooltip: {
                        formatter: function() {
                            return '<b>'+ this.x +'</b><br/>'+
                                '企业数：'+ Highcharts.numberFormat(this.y, 0) +
                                ' 个';
                        }
                    },
                    buttons:{    //配置按钮选项
                    	url: '<?php echo $path;?>export.php',
                        exportButton:{    //配置导出按钮
                            width:20,
                            symbolSize:15,
                            borderWidth:1,
                            borderRadius:0,
                            hoverBorderColor:'red',
                            height:20,
                            symbolX:10,
                            symbolY:10,
                            x:-50,
                            y:20
                        },
                    	filename:'<?php echo "企业信息来源分布柱状图"; ?>',//导出的文件名
                   		 type:'image/png',//导出的文件类型
                  },
                    series: [{
                        allowPointSelect: false,
                        cursor: 'pointer',
                        name: 'company',
                        data: [<?php echo $str_comps;?>],
                        dataLabels: {
                            enabled: true,
                            rotation: -90,
                            color: '#FFFFFF',
                            align: 'right',
                            x: -3,
                            y: 10,
                            formatter: function() {
                                return this.y;
                            },
                            style: {
                                fontSize: '13px',
                                fontFamily: 'Verdana, sans-serif'
                            },
                        },
                    }]
                });
            });
            
        });

        $(function () {
            var chart;
            $(document).ready(function() {
                chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'piecontainer',
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: '<?php echo "企业信息来源分布饼图"; ?>'
                    },
                    tooltip: {
                        pointFormat: '<b>{point.percentage}%</b>',
                        percentageDecimals: 2
                    },
                    buttons:{    //配置按钮选项
                    	url: '<?php echo $path;?>export.php',
                        exportButton:{    //配置导出按钮
                            width:20,
                            symbolSize:15,
                            borderWidth:1,
                            borderRadius:0,
                            hoverBorderColor:'red',
                            height:20,
                            symbolX:10,
                            symbolY:10,
                            x:-50,
                            y:20
	                        },
	                    filename:'<?php echo "企业信息来源分布饼图"; ?>',//导出的文件名
	                    type:'image/png',//导出的文件类型
                  },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                color: '#000000',
                                connectorColor: '#000000',
                                formatter: function() {
                                    return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage,2) +' %';
                                }
                            },
                            events: {
                                click: function (e) {
									//console.log(e.point.name);
									window.open("<?php echo $path ?>companys/index?source_name="+e.point.name);
                                }
                            }
                    
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: '',
                        data: [<?php echo $piepoint;?>]
                    }]
                });
            });
            
        });

                
        </script>
    </div>
    <div class="right_side_operate_area">
            <div class="right_side_head_line">
                <ul>
                <?php 
                    echo "<li><div class='left screen_condition'>&nbsp</div><div class='clear'></div>";
                        echo "<div class='left screen_condition'>企业数(个)</div><div class='clear'></div>";
                        echo "<div class='left screen_condition'>资金(万)</div><div class='clear'></div>";
                        echo "<div class='left screen_condition'>面积(㎡)</div><div class='clear'></div>";
                        echo "</li>";
                    $totalcomp = 0;
                    $totalcap = 0;  
                    $totalsize = 0;
                   
                    foreach($ind_comps as $ind_comp){
                    	$industryid=$ind_comp["codevalues"]["id"];
                        $industry = $ind_comp["codevalues"]["value"];
                        $countcomp = $ind_comp[0]["comps"];
                        $totalcomp += $countcomp;
                        $sumcapital = $ind_comp[0]["capital"];
                        if(!$sumcapital){
                            $sumcapital = "0.000";
                        }
                        $totalcap += $sumcapital;
                        $sumsize = $ind_comp[0]["size"];
                        if(!$sumsize){
                            $sumsize = "0.000";
                        }
                        $totalsize += $sumsize;
                        
                        echo "<li><div class='left screen_condition'><a>".$industry."</a></div><div class='clear'></div>";
                        echo "<div class='left screen_condition'></div><div class='left screen_counts'><a href='".$path."companys/index/modified/desc?seach=all&industry=".$industryid."'>".$countcomp."</a></div><div class='clear'></div>";
                        echo "<div class='left screen_condition'></div><div class='left screen_counts'>".$sumcapital."</div><div class='clear'></div>";
                        echo "<div class='left screen_condition'></div><div class='left screen_counts'>".$sumsize."</div><div class='clear'></div>";
                        echo "</li>";
                    }
                 ?>
                    <li>
                        <div class='left screen_condition'><a>总计</a></div><div class='clear'></div>
                        <div class='left screen_condition'></div><div class='left screen_counts'><?php echo $totalcomp; ?></div><div class='clear'></div>
                        <div class='left screen_condition'></div><div class='left screen_counts'><?php echo $totalcap; ?></div><div class='clear'></div>
                        <div class='left screen_condition'></div><div class='left screen_counts'><?php echo $totalsize; ?></div><div class='clear'></div>
                    </li>
                </ul>
            </div>
                            <?php
    	echo '<div class="right back_btn" style="float:left">';
		echo $html->link("导出",$path."reports/compinfo/1",array("target"=>"blank"));
		echo '</div>';
	?>
        </div>
    
</div>
<script>
$(document).ready(function() {
	$("#ddlgroup").change(function(){
		searchtech();
		});

});

function searchtech()
{		
	var webpath=$("#getpath").attr('href');
	var urlpath=webpath+"reports/compinfo?seach=all";
	var group=$("#ddlgroup").val();
	if(group==""){
		location.href=urlpath;
	}else{
		if(group!=""){
			urlpath+="&group="+group;
			}
		location.href=urlpath;
	}
	return false;

	}

</script>



